package com.test.api.update.controller;

import com.alibaba.fastjson.JSON;
import com.test.constant.FunCodeConstant;
import com.test.message.Message;
import com.test.message.RechargeResponseMessage;
import com.test.model.ConnectionManager;
import com.test.server.SyncFuture;

public class RechargeController {
    public static void main(String[] args) {
        String imei = "222222";

        SyncFuture<String> stringSyncFuture = new SyncFuture<>();

        RechargeResponseMessage rechargeResponseMessage = new RechargeResponseMessage();
        rechargeResponseMessage.setRechargeMoney(11.8);
        rechargeResponseMessage.setCapacity(12.00);
        rechargeResponseMessage.setUnitPrice(2.0);

        Message message = new Message();
        message.setFunCode(FunCodeConstant.RECHARGE_MONEY.byteValue());
        message.setHead((short) 0xAA);

        byte[] bytes = JSON.toJSONBytes(rechargeResponseMessage);
        message.setMessageLength((short) bytes.length);
        message.setMessageData(bytes);
        ConnectionManager.sendSyncMsg(stringSyncFuture, message, imei);
    }
}
